package com.xxx.corejava.day1216;

public class TestException {

    public static void main(String[] args) {
//        f1();


//        f2();


        System.out.println(f3());
    }

    public static void f1() throws Exception{
//        int i=1/0;

        Exception e=new Exception("异常消息");

        throw e;

    }

    public static void f2(){

        try {
            Exception e=new Exception("异常消息");

            throw e;
        } catch (Exception ex) {
            System.out.println("异常处理代码");
        }
    }

    public static int f3(){

        try {
            System.out.println("try");
            int i=1/0;
            return 1;
        } catch (Exception e) {
            System.out.println("catch");
//            System.out.println(e.getMessage());
//            e.printStackTrace();
            return 2;
        } finally {
            System.out.println("finally");
            return 3;
        }

    }
}
